package engine

import (
	"learngo/crawler/fetcher"
	"log"
)

func Worker (r Request)  (ParserResult, error){
	log.Printf("fetching %s", r.Url)
	body, err := fetcher.Fetcher(r.Url)
	if err != nil {
		log.Printf("Error fetching by url %s:%v", r.Url,err)
		return ParserResult{}, err
	}
	//调用具体的Parser方法
	return r.Parser.Parse(body, r.Url), nil
}
